package com.bwie.lib_core.imgload;

import android.util.Log;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bwie.lib_core.filed.UrlFiled;

public class BasicImageLoader extends ImageLoader {

    protected BasicBuilder builder;

    @Override
    public void load() {
        builder.load();
    }

    public static class BasicBuilder{
        private String url;
        private ImageView img;
        protected BasicImageLoader loader;
        public BasicBuilder setUrl(String url) {
            this.url = url;
            return this;
        }

        public BasicBuilder setImg(ImageView img) {
            this.img = img;
            return this;
        }

        protected void load(){
            Log.e("ZXY","BasicImageLoader:"+UrlFiled.IMGURL+url);
            Glide.with(img.getContext()).load(UrlFiled.IMGURL+url).
                    placeholder(loader.holderImg).into(img);
        }

        public BasicImageLoader build(){
            if (loader == null){
                loader = new BasicImageLoader();
                loader.builder = this;
            }
            return loader;
        }
    }

}
